package com.zhouheng.springbootdesignpattern.strategicpattern;

import java.math.BigDecimal;

/**
 * 测试策略模式
 *
 * @author 周恒
 * @date 20200120 15:23:40
 * @since v1.0
 */
public class Client {

    private static final String STR = "%s客户报价：%s";

    public static void main(String[] args) {
        BigDecimal money = new BigDecimal(100);
        // 老客户
        QuoteContext quoteContext = new QuoteContext(new OldCustomerQuoteStrategy());
        BigDecimal price = quoteContext.getPrice(money);
        System.out.println(String.format(STR, "老", price));

        // 新客户
        quoteContext = new QuoteContext(new NewCustomerQuoteStrategy());
        price = quoteContext.getPrice(money);
        System.out.println(String.format(STR, "新", price));

        // vip客户
        quoteContext = new QuoteContext(new VipCustomerQuoteStrategy());
        price = quoteContext.getPrice(money);
        System.out.println(String.format(STR, "VIP", price));
    }

}
